/**
 * 
 */
package com.antilia.infomaresme.pages.messages;

import java.util.ArrayList;
import java.util.List;

import org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow;
import org.apache.wicket.extensions.ajax.markup.html.repeater.data.table.AjaxFallbackDefaultDataTable;
import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn;
import org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.ResourceModel;

import com.antilia.infomaresme.InfomaresmeSession;
import com.antilia.infomaresme.data.dataobjects.User;
import com.antilia.infomaresme.data.dataobjects.UserMessage;
import com.antilia.infomaresme.provider.MessagesDataProvider;
import com.antilia.infomaresme.resources.InfoModalWindow;

/**
 * @author Ernesto
 *
 */
public class ListMessagesPanel extends Panel {

	private static final long serialVersionUID = 1L;

	private MessagesDataProvider dataProvider;
	
	private AjaxFallbackDefaultDataTable<UserMessage> items;
	
	private ModalWindow modal;
	
	/**
	 * @param id
	 */
	public ListMessagesPanel(String id) {
		super(id);
		modal = new InfoModalWindow("modal");
		modal.setTitle("Detalles");
		modal.setInitialHeight(640);
		modal.setInitialWidth(950);
		modal.setResizable(false);
		add(modal);
		
		List<IColumn<UserMessage>> columns = new ArrayList<IColumn<UserMessage>>();	
		/*
		columns.add(new PropertyColumn<Item>(Model.of(""), null , "price") {
			
			private static final long serialVersionUID = 1L;

			@Override
			public void populateItem(
					org.apache.wicket.markup.repeater.Item<ICellPopulator<Item>> item,
					String componentId, final IModel<Item> rowModel) {
				
			}
		});
		*/
		columns.add(new PropertyColumn<UserMessage>(new ResourceModel("message.subject"), null, "subject"));
		columns.add(new PropertyColumn<UserMessage>(new ResourceModel("date"), "date", "date"));
		columns.add(new PropertyColumn<UserMessage>(new ResourceModel("text"), null, "text"));
		
		
		
 		dataProvider = new MessagesDataProvider() {
 			
 			private static final long serialVersionUID = 1L;

 			
 			public User getUser() {
 				return InfomaresmeSession.getSession().getUser();
 			};
 
 		};		
		items  = new AjaxFallbackDefaultDataTable<UserMessage>("items", columns, dataProvider, 10);
		items.setOutputMarkupId(true);
		addOrReplace(items);
	}

}
